const puppeteer=require('puppeteer');
const sqlite3=require('sqlite3')
const ccurl="http://27.155.33.94:8102/"
const launchconf={
    executabPath:"D:/wd/chrome-win32/chrome.exe",
    headless:false
}
const wd=puppeteer.launch(launchconf);
const mydb=new sqlite3.Database('e:/cc.db');
var sql=""; 
(async()=>{
 var i,j,k,k1,t1,t2,t3
 var  p1=wd.newPage();
 await p1.goto(ccurl) ;
 await p1.$("[ext\\:tree-node-id='1']").click();
 await p1.$("[ext\\:tree-node-id='913']").click();
 await p1.$("[ext\\:tree-node-id='925']").click();
 i=p1.$(".x-tree-node-ct","#ext-gen166");
 for (j in i.children()){
  await j.click(); 
  t1=j.innerText;   
  k=p1.$("#ext-gen195,.x-grid3-row")
  k.each(function(){
    k1=this.chldren('table').children('tbody').children('td');
    t2=k1.children("td:has(a)").text();
    k1.children("td:contains('上报')").click();
    wd.sleep(1)
    t3=p1.$('ext-comp-1178').text();
    sql="insert into main values('t1='&a[0]',t2='&a[1])')"
    mydeb.exec(sql); 
    p.$("#ext-gen66").children().remove();        
  });
 };
mydb.close();
})

   //tasknum=k[2]
   //nownum-k[3]

